#!/usr/bin/env python3
"""
脚本名称：ch41_exe.py
功能描述： 物以类聚
作者：Gavin
创建日期：2022-05-06
版本：1.0
依赖库：无
使用方法： python ch41_exe.py
"""


class TheThing(object):
    # __init__ 是一个特殊的初始方法，可以预设重要的变量在里边
    def __init__(self):
        self.number = 0

    def some_function(self):
        print("I got called.")

    def add_me_up(self, more):
        self.number += more
        return self.number


# two different things
a = TheThing()
b = TheThing()
a.some_function()
b.some_function()
print(a.add_me_up(20))
print(b.add_me_up(30))
print(a.number)
print(b.number)


# Study this. This is how you pass a variable
# from one class to another. You will need this.
class TheMultiplier(object):
    def __init__(self, base):
        self.base = base

    def do_it(self, m):
        return m * self.base


x = TheMultiplier(a.number)
print(x.do_it(b.number))
